﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using System.IO;

namespace MailSenderPro.Util
{
    [Serializable]
    public class MailAlici
    {
        public string Ad { get; set; }
        public string EMail { get; set; }
        public bool IslemGordu { get; set; }
    }

    public class Globals
    {
        private static List<SmtpItem> _SmtpList;

        public static List<SmtpItem> SmtpList
        {
            get
            {
                if (_SmtpList == null)
                {
                    string path = Application.StartupPath + "\\smtp.bin";
                    if (File.Exists(path))
                    {
                        FileStream fs = new FileStream(path, FileMode.Open);
                        BinaryFormatter formatla = new BinaryFormatter();
                        _SmtpList = formatla.Deserialize(fs) as List<SmtpItem>;
                    }
                    else
                        _SmtpList = new List<SmtpItem>();
                }
                return _SmtpList; 

            }
            set
            {
                _SmtpList = value; 
            }
        }
        private static List<MailAlici> _MailList;

        public static List<MailAlici> MailList 
        {
            get 
            {
                if (_MailList == null)
                {
                    string path = Application.StartupPath + "\\mails.bin";
                    if (File.Exists(path))
                    {
                        FileStream fs = new FileStream(path, FileMode.Open);
                        BinaryFormatter formatla = new BinaryFormatter();
                        _MailList = formatla.Deserialize(fs) as List<MailAlici>;
                    }
                    else
                        _MailList = new List<MailAlici>(); 
                }
                return _MailList; 
            }
            set { _MailList = value; } 
        }
    }
}
